home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
LOGIC Apps
/
Logic-APPLE_II_APPS.iso
/
pc
/
LOGIC Apple II 5.25" Library - DOS Part 2
/
DOS033.dsk
/
GAMBLER'S RUIN.bas
< prev
next >
Wrap
BASIC Source File
|
2012-02-16
|
4KB
|
114 lines
10 CLEAR : HOME
20 PRINT TAB( 12)"GAMBLER'S RUIN"
30 PRINT
40 PRINT TAB( 8)"H.EDELSTEIN NOV 29,1979"
50 PRINT
60 PRINT " SHOWS HOW THE GAMBLER IS RUINED"
70 PRINT "EVEN IF THE ODDS ARE 'FAIR'...THAT IS,"
80 PRINT "EVEN IF HOUSE PERCENT IS CLOSE TO ZERO."
90 PRINT " THE PLAYER'S NET GAIN OR LOSS"
100 PRINT "IS PLOTTED AFTER EACH PLAY."
110 PRINT
120 PRINT " HERE ARE SUGGESTED STARTING VALUES:"
130 PRINT " HOUSE FUNDS: $1000
140 PRINT " HOUSE PERCENTAGE: 5 "
150 PRINT " PLAYER'S FUNDS: $25
160 PRINT " ODDS(E.G. 9 TO 1): 9"
170 PRINT " SIZE OF BET: $1
180 PRINT
190 PRINT "NOW ENTER THESE VALUES OR YOUR OWN:"
200 INPUT " HOUSE FUNDS: $";RH
210 INPUT " HOUSE PERCENTAGE: ";HPCT
220 INPUT " PLAYER'S FUNDS: $";RP
230 IF RP >100 THEN PRINT "SORRY......": PRINT "WE DON'T ALLOW YOU LOSE MORE THAN $100.": GOTO 220
240 INPUT " ODDS: ";ODDS
250 PW = INT((1 -(HPCT/100)) *1000 *(1/(ODDS +1)) +.5)/1000
260 PRINT " (PROB. OF WIN IS: ";PW
270 INPUT " SIZE OF BET: $";B
280 HOME
310 R = RP
320 H = RH
330 P = PW
340 PA = B *ODDS
350 FOR J = 1 TO 100
360 HGR : HCOLOR= 3
370 HPLOT 0,0 TO 0,159
380 HPLOT 0,50 TO 200,50
390 HPLOT 205,25 TO 225,25
400 HPLOT 215,15 TO 215,35
410 HPLOT 205,65 TO 225,65
420 HPLOT 0,50 +R TO 200,50 +R
430 VTAB 22
460 PRINT TAB( 10)"YOU ARE : $"
470 FOR LOOP = 1 TO 100
480 PLAY = RND(1)
490 IF PLAY >P THEN LET L = L +1:RH = RH +B:RP = RP -B: GOTO 520
500 IF PLAY < = P THEN LET W = W +1:RH = RH -PA:RP = RP +PA
510 IF RH < = 0 THEN GOSUB 5000: GOTO 660
520 Y = 50 -(W *PA -L *B)
522 G = Y
525 IF Y > = 159 THEN LET Y = 159
540 IF Y <0 THEN LET Y = 0
542 IF (50 -G) <0 THEN GOSUB 6000
544 IF (50 -G) > = 0 THEN GOSUB 6020
550 VTAB 22: HTAB 32: PRINT 50 -G;" "
555 VTAB 22: HTAB 19: PRINT R$
560 HPLOT LOOP *2,Y
570 N = N +1:FR = W/(W +L):F = INT(FR *1000)/1000
580 IF RP < = 0 THEN GOSUB 4000
590 IF RP < = 0 GOTO 640
592 V = PEEK( -16384)
594 IF V >127 THEN GOTO 660
600 NEXT LOOP
610 NEXT J
620 VTAB 24: PRINT "YOU HAVE NOW HAD 10,000 PLAYS."
630 PRINT "CASH IN YOUR CHIPS:PRESS SPACE BAR.": GET A$: GOTO 660
640 VTAB 24
650 PRINT "YOU ARE WIPED OUT ! PRESS SPACE BAR.": GET A$
660 TEXT : HOME
670 PRINT " BEFORE PLAY"
680 PRINT " -----------------"
690 PRINT " HOUSE FUNDS: $";H
700 PRINT "PLAYER'S FUNDS: $";R
710 PRINT " BET: $";B
720 PRINT "HOUSE PERCENTAGE IS ";HPCT;" WITH ODDS ";ODDS;" TO 1."
730 PRINT "PLAYER'S PROBABILITY OF WIN: ";P
740 PRINT
750 PRINT " AFTER PLAY"
760 PRINT " -----------------"
770 PRINT "NO. OF PLAYS: ";N
780 PRINT "NO. OF WINS: ";W
790 PRINT "NO. OF LOSSES: ";L
800 PRINT "FRACTION WON: ";F
810 PRINT "HOUSE FUNDS: $";RH
820 PRINT "PLAYER'S FUNDS: $";RP
830 PRINT
840 RUIN = INT(100000 *(H/(H +R)))/100000
850 IF HPCT = 0 THEN LET NP = H *R: GOTO 870
860 NP = INT(R/(HPCT *.01) +.5)
870 PRINT "ACCORDING TO PROBABILITY THEORY,"
880 PRINT "YOUR PROBABILITY OF RUIN WAS ";RUIN
890 PRINT "WITHIN ";NP;" PLAYS."
900 PRINT "SEE 'LADY LUCK' BY WEAVER (ANCHOR BOOKS)"
920 INPUT "DO YOU WANT TO GAMBLE AGAIN? ";A$
930 IF LEFT$(A$,1) = "Y" GOTO 10
940 HOME
950 VTAB 10
960 PRINT TAB( 16)"VERY WISE!"
970 FOR Z = 1 TO 1000: NEXT Z
980 HOME : END
4000 FOR FQ = 1 TO 100
4010 TN = PEEK( -16336)
4020 NEXT FQ
4030 RETURN
5000 TEXT : HOME : VTAB 10
5010 PRINT TAB( 18)"LUCKY YOU !"
5020 PRINT : PRINT : PRINT
5030 PRINT TAB( 10)"YOU BROKE THE HOUSE !"
5040 PRINT : PRINT : PRINT : PRINT : PRINT "(BUT ONLY BECAUSE IT WAS LOW IN FUNDS...THIS TIME.)"
5050 FOR Z = 1 TO 2500: NEXT Z
5060 RETURN
6000 R$ = "LOSING "
6010 RETURN
6020 R$ = "WINNING"
6030 RETURN